package pf.springBoot.springBootMetabaseLogin;

import java.nio.file.Paths;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.fastjson.JSON;
import com.perfect99.right.amsweb.ActionReturnInfo;
import com.perfect99.right.amsweb.ActionValidate;
import com.perfect99.right.amsweb.ActionValidateSoap;
import com.perfect99.right.amsweb.BaseReturnInfo;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import pf.java.pfHelper.config.PFDataHelper;
import pf.springBoot.springBootSSO.service.BalanceService;

/*
 * 文件生成到D:\eclipse_workspace_springBoot\springBootMetabaseLogin\target\test-classes
 */
public class GenerateLocalJson //extends TestCase
{
	private static ActionValidateSoap _service;
	private static String userid="1712002";
    @Autowired
    private static BalanceService _balanceService;
//    /**
//     * Create the test case
//     *
//     * @param testName name of the test case
//     */
//    public GenerateLocalJson( String testName )
//    {
//        super( testName );
//        //创建一个WeatherWS工厂
//    	ActionValidate factory = new ActionValidate();
//        //根据工厂创建一个WeatherWSSoap对象
//    	ActionValidateSoap weatherWSSoap = factory.getActionValidateSoap();
//    	 _service= weatherWSSoap;
//    }
//    /**
//     * @return the suite of tests being tested
//     */
//    public static Test suite()
//    {
//        return new TestSuite( AppTest.class );
//    }
//
//    /**
//     * Rigourous Test :-)
//     */
//    public void testApp()
//    {
//        assertTrue( true );
//    }
	
    /**
     * 测试
     * @param args
     */
    public static void main(String[] args) throws Exception{
	      //创建一个WeatherWS工厂
	  	ActionValidate factory = new ActionValidate();
	      //根据工厂创建一个WeatherWSSoap对象
	  	ActionValidateSoap weatherWSSoap = factory.getActionValidateSoap();
	  	 _service= weatherWSSoap;
	  	 
	  	GenerateLoginCheck();
	  	GenerateGetAllAction();
    }
    
    private static void GenerateLoginCheck() {
    	BaseReturnInfo dt =_service.loginValidate(userid, "1712002");
    	String json = JSON.toJSONString(dt);
    	String filename = Paths.get(PFDataHelper.GetBaseDirectory(), "LoginCheck.json").toString();
    	PFDataHelper.SaveStringToFile(json,filename);
    }
    private static void GenerateGetAllAction()
    {
    	ActionReturnInfo dt = _service.getAllAction("1712002", "YJQ", null, null, null, null, null);
    	String json = JSON.toJSONString(dt);
    	String filename = Paths.get(PFDataHelper.GetBaseDirectory(), "GetAllAction.json").toString();
    	PFDataHelper.SaveStringToFile(json,filename);
    }
//    private static void GenerateGetMeshwork()
//    {
//        var dt = _balanceService.GetMeshwork("00001118", "D1", 5);
//        var list = PFDataHelper.DataTableToDictList(dt, false);
//        //var json = DataTableConvertJson.DataTable2Json(dt);
//        var json = JsonConvert.SerializeObject(list);
//        //Console.Write(json);
//        string filename = Path.Combine(PFDataHelper.BaseDirectory, "GetMeshwork.json");
//    	PFDataHelper.SaveStringToFile(json,filename);
//    }
}
